﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://wubiyu.cnblogs.com">
<head>
      <title></title>
      <link href="../../Theme/DomExtGray/gray.min.css" rel="Stylesheet" type="text/css" />
      <link href="PageModel.css" rel="Stylesheet" type="text/css" />
      <script type="text/javascript" src="../../domExt.min.js"></script>
</head>
<body>
      <div class="fun_title">
            _h.ready(fn);
      </div>
      <div class="fun_content">
            描述：选择器方法 ，可根据Id、标签名、样式名获取DOM对象。<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当没有传入context参数时，将在整个DOM集合对象中查找，否则在相应的DOM集合中查找。</div>
      <div class="fun_title2">
            参数:
      </div>
      <div class="fun_content2">
           expression：<br />
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            #id：据给定的ID匹配一个元素<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            element ：根据给定的元素名匹配所有元素。<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            .className：根据样式名称匹配所有元素。
            <br />
           [context]：<br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            作为待查找的 DOM 元素集。<br />
            <strong>Retrun:</strong><br />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            DOM对象<br /><br />
      </div>
      <div class="fun_title2">
            示例:
      </div>
      <div class="code">
            &lt;div id=&quot;div1&quot;&gt;&lt;div class=&#39;testclass&#39;&gt;testdiv&lt;/div&gt;&lt;/div&gt;
      </div>
      <input type="hidden" value="<div id='div1'><div class='testclass'>testdiv</div></div>"
            id="htmlcode">
      <div class="code">
            &lt;script type=&quot;text/javascript&quot;&gt;<br />
            &nbsp;&nbsp;&nbsp; var div1 = _g(&quot;#div1&quot;);&nbsp;&nbsp;&nbsp;
            <br />
            &nbsp;&nbsp;&nbsp; var <i>collObjects1=_g(&quot;div&quot;);</i><br />
            &nbsp;&nbsp;&nbsp; var <i>collObjects2=_g(&quot;.testclass&quot;,div1);</i><br />
            &nbsp;&nbsp;&nbsp; alert(div1.innerHTML);<br />
            &lt;/script&gt;</div>
      <input type="hidden" value=" var div1 = _g('#div1');  var collObjects1=_g('div');var collObjects2=_g('.testclass',div1);alert(div1.innerHTML);"
            id="jscode">
      <br />
      <h:btn onclick="run_click();">执行脚本</h:btn>
      <div id="htmltemp" style="display:none;"></div>
      <script type="text/javascript">
            function run_click() {
                  var htmltemp = _g("#htmltemp");
                  var htmlcode = _g("#htmlcode");
                  htmltemp.innerHTML = htmlcode.value;
                  var jscode = _g("#jscode");
                  eval(jscode.value);
            }
      </script>
</body>
</html>
